package com.aspose.cells;

import java.util.ArrayList;
import java.util.HashMap;

class zaup {
   boolean a;
   private ArrayList c;
   int b;

   zaup(boolean var1, int var2) {
      this.a = var1;
      this.c = new ArrayList();
      this.b = var2;
   }

   void a(Object var1, int var2) {
      if (var1 == null) {
         this.a(0.0D, var2);
      } else {
         double var3;
         if (var1 instanceof Double) {
            var3 = (Double)var1;
            this.a(var3, var2);
         } else if (var1 instanceof Integer) {
            var3 = (double)(Integer)var1;
            this.a(var3, var2);
         } else if (var1 instanceof zst) {
            this.a((zst)var1, var2);
         } else if (var1 instanceof String && ((String)((String)var1)).length() == 0) {
            this.a(0.0D, var2);
         }
      }

   }

   private void a(double var1, int var3) {
      boolean var4 = false;

      for(int var5 = 0; var5 < this.c.size(); ++var5) {
         zauq var6 = (zauq)this.c.get(var5);
         if (var6.a instanceof zst) {
            zauq var11 = new zauq();
            var11.a = var1;
            com.aspose.cells.b.a.a.ze.a(var11.b, (Object)var3);
            this.c.add(var5, var11);
            var4 = true;
            break;
         }

         double var7 = (Double)var6.a;
         if (var7 == var1) {
            com.aspose.cells.b.a.a.ze.a(var6.b, (Object)var3);
            var4 = true;
            break;
         }

         if (var1 < var7) {
            zauq var9 = new zauq();
            var9.a = var1;
            com.aspose.cells.b.a.a.ze.a(var9.b, (Object)var3);
            this.c.add(var5, var9);
            var4 = true;
            break;
         }
      }

      if (!var4) {
         zauq var10 = new zauq();
         var10.a = var1;
         com.aspose.cells.b.a.a.ze.a(var10.b, (Object)var3);
         com.aspose.cells.b.a.a.ze.a(this.c, (Object)var10);
      }

      if (this.c.size() > this.b) {
         if (this.a) {
            this.c.remove(0);
         } else {
            this.c.remove(this.c.size() - 1);
         }
      }

   }

   private void a(zst var1, int var2) {
      boolean var3 = false;
      int var4 = zakq.a(var1);

      for(int var5 = 0; var5 < this.c.size(); ++var5) {
         zauq var6 = (zauq)this.c.get(var5);
         if (var6.a instanceof zst) {
            int var7 = zakq.a((zst)var6.a);
            if (var4 == var7) {
               com.aspose.cells.b.a.a.ze.a(var6.b, (Object)var2);
               var3 = true;
               break;
            }

            if (var4 < var7) {
               zauq var8 = new zauq();
               var8.a = var1;
               com.aspose.cells.b.a.a.ze.a(var8.b, (Object)var2);
               this.c.add(var5, var8);
               var3 = true;
               break;
            }
         }
      }

      if (!var3) {
         zauq var9 = new zauq();
         var9.a = var1;
         com.aspose.cells.b.a.a.ze.a(var9.b, (Object)var2);
         com.aspose.cells.b.a.a.ze.a(this.c, (Object)var9);
      }

      if (this.c.size() > this.b) {
         if (this.a) {
            this.c.remove(0);
         } else {
            this.c.remove(this.c.size() - 1);
         }
      }

   }

   HashMap a() {
      HashMap var1 = new HashMap();

      for(int var2 = 0; var2 < this.c.size(); ++var2) {
         zauq var3 = (zauq)this.c.get(var2);

         for(int var4 = 0; var4 < var3.b.size(); ++var4) {
            var1.put(var3.b.get(var4), true);
         }
      }

      return var1;
   }
}
